import { createRouter, createWebHashHistory } from 'vue-router'
import layout from '@/views/layout/index.vue'

/**
 * 公开的路由表
 */
const publicRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/login.vue')
  },
  {
    path: '/',
    // 重定向，重定到profile页面
    redirect: 'navigation',
    component: layout,
    children: [
      // 个人中心
      {
        path: '/personal',
        name: 'personal',
        component: () => import('@/views/personal/index.vue'),
        meta: {
          title: '个人中心'
        }
      },
      {
        path: '/navigation',
        name: 'navigation',
        component: () => import('@/views/navigation/index.vue'),
        meta: {
          title: '快捷导航',
          name: '快捷导航',
          icon: 'navigation'
        }
      },
      // 用户管理
      {
        path: '/usermanage',
        name: 'userManagement',
        component: () => import('@/views/user-manage/index.vue'),
        meta: {
          title: '用户管理',
          name: '用户管理',
          icon: 'personnel'
        }
      },
      {
        path: '/system',
        meta: {
          title: '系统配置',
          // name: '用户',
          icon: 'system'
        },
        component: () => import('@/views/system/index.vue'),
        children: [
          // 用户管理
          {
            path: '/system/equipment',
            component: () => import('@/views/equipment-set/index'),
            meta: {
              title: '设备设置',
              name: '设备设置',
              icon: 'equipment'
            }
          },
          // 角色列表
          {
            path: '/system/production',
            component: () => import('@/views/production-line/index'),
            meta: {
              title: '产线设置',
              name: '产线设置',
              icon: 'production'
            }
          },
          // 隔间设置
          {
            path: '/system/compartment',
            component: () => import('@/views/compartment-install/index'),
            meta: {
              title: '隔间设置',
              name: '隔间设置',
              icon: 'compartment'
            }
          },
          // 工位设置
          {
            path: '/system/settingup',
            component: () => import('@/views/settingup/index'),
            meta: {
              title: '工位设置',
              name: '工位设置',
              icon: 'station'
            }
          }
          // 导入
          // {
          //   path: '/system/import',
          //   name: 'import',
          //   component: () => import('@/views/import/index'),
          //   meta: {
          //     name: 'exce导入',
          //     title: 'exce导入'
          //   }
          // }
        ]

      },
      // 吧上面的路由放在这里
      {
        path: '/system/control',
        component: () => import('@/views/control-model/index'),
        meta: {
          title: '控制系统',
          name: '控制系统',
          icon: 'control'
        }
      },

      // 404
      {
        path: '/404',
        name: '404',
        component: () => import('@/views/error-page/404.vue')
      },
      // 401
      {
        path: '/401',
        name: '401',
        component: () => import('@/views/error-page/401.vue')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: publicRoutes
})

export default router
